<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/vue.js" type="text/javascript"></script>
</head>
<body>
    <div id="box">
        {{10+20}}
        <p>{{myname}}</p>
        <div v-html="myhtml"></div>
        <div v-show="isShow">动态显示和隐藏</div>
        <div v-if="isCreate">动态创建和删除</div>
        <div style="background: yellow;">11111</div>
        <button @click=handleClick()>click</button>
        <div :class="isActive?'red':'yellow'">我是动态绑定class-三目写法</div>
        <div :class="classobj">我是动态绑定class-对象写法</div>
        <div :class="classarr">我是动态绑定class-数组写法</div>

        
        <div :style="'background:'+(isActive?'red':'yellow')">我是动态绑定style-三目写法</div>
    </div>
    <div>
        {{10+20}}
    </div>
    <script>
        /* v-html 防止xss,csrf攻击{前端过滤，后台转义，给cookie加上属性http} */
        var vm = new Vue({
            el:"#box", //vue 渲染开始的地方
            data:{
                myname:"zmj",
                isCreate:true,
                isActive:true,
                isShow:true,
                myhtml:"<b>zch</b>",
                classobj:{   //对象添加c属性，没有get和set的属性拦截，不会生效
                    a:true,
                    b:true
                },
                classarr:['a','b']
            },
            methods:{
                handleClick(){
                    this.isActive = !this.isActive;
                }
            }
        })
    </script>
    <style>
        .red{background: red;}
        .yellow{background: yellow;}
    </style>
</body>
</html>